Welcome Guest | Sign in | Register

Home > C Programming > If statements > Questions and Answers

01. What is the output of following program?
void main(){
float a;
a=6.7;
if(a==6.7)
printf("A");
else
printf("B");
}
A. A B. B
C. error D. nothing display on screen

Answer and Explanation

Answer: B

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
02. What will be output of the following program?
#include
int main()
{
float a=0.7;
if(a<0.7){
printf("C");
} else{
printf("C++");
}
return 0;
}  
A. C B. C++
C. NULL D. Compilation error
E. None of these

Answer and Explanation

Answer: C

Explanation:
0.7 is double constant (Default). Its binary value is written in 64 bit. Binary value of 0.7 = (0.1011 0011 0011 0011 0011 0011 0011 0011 0011 0011 0011) Now here variable a is a floating point variable while 0.7 is double constant. So variable a will contain only 32 bit value i.e. a = 0.1011 0011 0011 0011 0011 0011 0011 0011 while 0.7 = 0.1011 0011 0011 0011 0011 0011 0011 0011 0011 0011 0011.... It is obvious a < 0.7  

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
03. What will be output when you will execute following c code?
#include
void main(){
int a=100;
if(a>10)
printf("M.S. Dhoni");
else if(a>20)
printf("M.E.K Hussey");
else if(a>30)
printf("A.B. de villiers");
}
A. M.S. Dhoni B. A. B. de Villiers
C. M.S. Dhoni M.E.K Hussey A.B. de Villiers D. Compilation Error

Answer and Explanation

Answer: M.S. Dhoni

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
04. What will be output when you will execute following c code?
#include
void main(){
int a=5,b=10;
if(++a||++b)
printf("%d %d",a,b);
else
printf("John Terry");
}
A. 5 10 B. 6 11
C. 6 10 D. 5 11

Answer and Explanation

Answer: 6 10

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum



Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.